home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / cpp-olib.zip / DEMOS.ZIP / TUIDEMO.CPP < prev    next >
C/C++ Source or Header  |  1992-12-28  |  25KB  |  1,062 lines

  1. //**************************************************************************
  2. //    This is a demo program to show how to use some of the features of
  3. //    the TUI libraries of the ObjectEase package. To compile and run this
  4. //    program create a project file including the files TUI_L.LIB and
  5. //    TUIDEMO.CPP. Make sure that the files in the project are located where
  6. //    the project says they are. You may also need to modify the path to
  7. //    TUI.H in the #includes portion of this file.
  8. //
  9. //    BE SURE YOU ARE COMPILING FOR THE LARGE MEMORY MODEL!!!
  10. //**************************************************************************
  11.  
  12. #include "tui.h"
  13. #include <conio.h>
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16.  
  17. //*************************  FUNCTION PROTOTYPES  **************************
  18.  
  19. void initialize();
  20. void introscreen();
  21. void explainscreen();
  22. void windowdemo();
  23. void menudemo();
  24. void stringdemo();
  25. void buttondemo();
  26. void checkboxdemo();
  27. void textmousedemo();
  28. void wrapup();
  29.  
  30. //***************************  GLOBAL VARIABLES  ***************************
  31.  
  32. extern Mcursor the_mouse;
  33.  
  34. //**************************************************************************
  35. //              MAIN
  36. //**************************************************************************
  37.  
  38. void main()
  39. {
  40.     initialize();
  41.     introscreen();
  42.     explainscreen();
  43.     windowdemo();
  44.     menudemo();
  45.     stringdemo();
  46.     buttondemo();
  47.     checkboxdemo();
  48.     textmousedemo();
  49.     wrapup();
  50.  
  51.     settext(7,0);
  52.     cursoron();
  53.     clrscr();
  54.     puts("Thank you for previewing the ObjectEase library from");
  55.     puts("David S. Reinhart Associates");
  56.     exit(0);
  57. }
  58.  
  59. //**************************************************************************
  60. //              INITIALIZE
  61. //**************************************************************************
  62.  
  63. void initialize()
  64. {
  65.     char ch;
  66.  
  67.     clrscr();
  68.     flushkeys();
  69.     if(!the_mouse.init()) {
  70.         puts("Mouse driver not found. If you have a mouse, press <ESC> now");
  71.         puts("to exit and load your mouse driver. Press any other key to continue.");
  72.         ch=getch();
  73.         if(ch==27)
  74.             exit(1);
  75.         }
  76.     cursoroff();
  77. }
  78.  
  79. //**************************************************************************
  80. //              INTROSCREEN
  81. //**************************************************************************
  82.  
  83. void introscreen()
  84. {
  85.     int done=0;
  86.     char ch;
  87.  
  88.     clear(32,1,1);
  89.     dlay(8);
  90.     smoved(37,1,7,14,1,"Welcome");
  91.     dlay(3);
  92.     smover(9,1,35,14,1,"To The World");
  93.     dlay(3);
  94.     smovel(11,79,40,14,1,"Of");
  95.     dlay(3);
  96.     smoveu(31,25,14,15,1,">>>  ObjectEase  <<<");
  97.  
  98.     Twindow creditwindow;
  99.     creditwindow.init(5,18,76,24,0,3,0,0);
  100.     creditwindow.setborder(DOUBLE);
  101.     creditwindow.zoom();
  102.     creditwindow.title(" DEMO ");
  103.     creditwindow.border();
  104.  
  105.     creditwindow.wprintc(2,15,3,"The ObjectEase Library Demo");
  106.     creditwindow.wprintc(3,15,3,"(c) Copyright 1992 - David S. Reinhart Asociates");
  107.     creditwindow.wprintc(5,14,3,"Press <ENTER> to continue...");
  108.  
  109.     while(!done) {
  110.         smover(16,25,53,11,1,"***");
  111.         if(kbhit()) {
  112.             ch=getch();
  113.             if(ch==13) {
  114.                 ungetch(ch);
  115.                 done=1;
  116.                 continue;
  117.                 }
  118.             }
  119.         smoveu(53,16,5,11,1,"***");
  120.         if(kbhit()) {
  121.             ch=getch();
  122.             if(ch==13) {
  123.                 ungetch(ch);
  124.                 done=1;
  125.                 continue;
  126.                 }
  127.             }
  128.         smovel(5,53,25,11,1,"***");
  129.         if(kbhit()) {
  130.             ch=getch();
  131.             if(ch==13) {
  132.                 ungetch(ch);
  133.                 done=1;
  134.                 continue;
  135.                 }
  136.             }
  137.         smoved(25,5,16,11,1,"***");
  138.         if(kbhit()) {
  139.             ch=getch();
  140.             if(ch==13) {
  141.                 ungetch(ch);
  142.                 done=1;
  143.                 continue;
  144.                 }
  145.             if(ch==27) {
  146.                 clrscr();
  147.                 exit(0);
  148.                 }
  149.             }
  150.         }
  151.     clear(32,1,1);
  152. }
  153.  
  154. //*************************************************************************
  155. //              EXPLAINSCREEN
  156. //*************************************************************************
  157.  
  158. void explainscreen()
  159. {
  160.     char ch;
  161.  
  162.     Twindow mainwindow;
  163.     mainwindow.init(1,1,80,25,15,1,0,0);
  164.     mainwindow.title(" ObjectEase ");
  165.     mainwindow.show();
  166.     mainwindow.divider(HOR,DOUBLE,2);
  167.     printc(2,14,1,"Text Mode Features");
  168.  
  169.     dlay(18);
  170. //WINDOW
  171.     Twindow demowindow;
  172.     demowindow.init(10,5,20,10,0,3,1,9);
  173.     demowindow.zoom();
  174.     printat(11,12,14,1,"Windows");
  175.     dlay(18*2);
  176. //MENU
  177.     Tmenu demomenu;
  178.     itemarray items;
  179.  
  180.     strcpy(items[1],"Item 1");
  181.     strcpy(items[2],"Item 2");
  182.     strcpy(items[3],"Item 3");
  183.  
  184.     demomenu.init(3,items,35,5,15,15,4,14,0,1,9);
  185.     demomenu.setborder(DOUBLE);
  186.     demomenu.show();
  187.     printat(39,12,14,1,"Menus");
  188.     dlay(18*2);
  189. //BUTTON
  190.     Tbutton button1;
  191.     button1.init(64,6," Start ",2);
  192.     Tbutton button2;
  193.     button2.init(64,8," Stop  ",3);
  194.  
  195.     button1.show(1);
  196.     button2.show(1);
  197.     printat(65,12,14,1,"Buttons");
  198.     dlay(18*2);
  199. //STRING
  200.     Tstring the_string;
  201.     Tdate the_date;
  202.  
  203.     the_string.init(20,18,15,0);
  204.     the_string.setincolors(14,0);
  205.     the_string.show();
  206.  
  207.     the_date.init(20,20);
  208.     the_date.setincolors(14,0);
  209.     the_date.show();
  210.  
  211.     printat(10,18,11,1,"Name: ");
  212.     printat(10,20,11,1,"Date: ");
  213.     printat(10,22,14,1,"String Input");
  214.     dlay(18*2);
  215. //CHECKBOX
  216.     Tcheckbox yesbox;
  217.     yesbox.init(60,18,15,1);
  218.     Tcheckbox nobox;
  219.     nobox.init(60,20,15,1);
  220.  
  221.     yesbox.show();
  222.     yesbox.check();
  223.  
  224.     nobox.show();
  225.  
  226.     printat(55,18,15,1,"Yes");
  227.     printat(55,20,15,1,"No ");
  228.     printat(55,22,14,1,"Check Boxes");
  229.     dlay(18*2);
  230.  
  231.     printc(24,15+128,1,"Press <ENTER> to continue");
  232.     flushkeys();
  233. getkey:
  234.     while(!kbhit());
  235.     ch=getch();
  236.     if(ch==27) {
  237.         clrscr();
  238.         exit(0);
  239.         }
  240.     if(ch!=13) {
  241.         flushkeys();
  242.         goto getkey;
  243.         }
  244. }
  245.  
  246. //*************************************************************************
  247. //              WINDOWDEMO
  248. //*************************************************************************
  249.  
  250. void windowdemo()
  251. {
  252.     char ch;
  253.  
  254.     clear(32,1,1);
  255.     dlay(12);
  256.     smover(12,1,37,14,1,"Windows");
  257.     dlay(18*2);
  258.     smover(12,37,74,14,1,"Windows");
  259.     clear(176,15,1);
  260.     dlay(18);
  261.  
  262.     printat(20,10,15,1,"With this simple piece of code...");
  263.     printat(25,12,15,1,"Twindow the_window;");
  264.     printat(25,13,15,1,"the_window.init(10,5,71,20,14,4,1,7);");
  265.     dlay(18*3);
  266.     printat(20,15,15,1,"You have created this window...");
  267.     dlay(18*3);
  268.  
  269.     Twindow demowindow;
  270.     demowindow.init(10,5,71,20,14,4,1,7);
  271.     demowindow.show();
  272.     dlay(18*3);
  273.  
  274.     printat(20,8,15,4,"Want to change the border?  Try this...");
  275.     printat(25,10,15,4,"the_window.setborder(DOUBLE);");
  276.     printat(25,11,15,4,"the_window.border();");
  277.     dlay(18*3);
  278.  
  279.     demowindow.setborder(DOUBLE);
  280.     demowindow.border();
  281.     dlay(18*3);
  282.  
  283.     printat(20,14,15,4,"Now to clear the window...");
  284.     printat(25,16,15,4,"the_window.fill();");
  285.     dlay(18*3);
  286.  
  287.     demowindow.fill();
  288.     dlay(18*3);
  289.  
  290.     printat(20,10,15,4,"Let's add a title. We'll call it Window 1.");
  291.     printat(25,12,15,4,"the_window.title(\"Window 1\");");
  292.     printat(25,13,15,4,"the_window.border();");
  293.     dlay(18*3);
  294.  
  295.     demowindow.title("Window 1");
  296.     demowindow.border();
  297.     dlay(18*3);
  298.     demowindow.fill();
  299.  
  300.     printat(20,10,15,4,"No, how about a heading instead of a title.");
  301.     printat(25,12,15,4,"the_window.divider(HOR,DOUBLE,2);");
  302.     printat(25,13,15,4,"the_window.wprintc(1,15,4,\"Window 1\");");
  303.     dlay(18*3);
  304.  
  305.     demowindow.title("");
  306.     demowindow.border();
  307.     demowindow.divider(HOR,DOUBLE,2);
  308.     demowindow.wprintc(1,15,4,"Window 1");
  309.     dlay(18*3);
  310.  
  311.     demowindow.hide();
  312.     clear(176,15,1);
  313.     dlay(18);
  314.  
  315.     printc(10,15,1,"You can display a window like this...");
  316.     printc(12,15,1,"the_window.show();");
  317.     dlay(18*3);
  318.  
  319.     demowindow.show();
  320.     dlay(18*2);
  321.     demowindow.hide();
  322.     clear(176,15,1);
  323.     dlay(18);
  324.  
  325.     printc(10,15,1,"Or ZOOM it like this...");
  326.     printc(12,15,1,"the_window.zoom();");
  327.     dlay(18*3);
  328.  
  329.     demowindow.zoom();
  330.     dlay(18*2);
  331.     printc(10,15,4,"Hide a window with this call...");
  332.     printc(12,15,4,"the_window.hide();");
  333.     dlay(18*3);
  334.  
  335.     demowindow.hide();
  336.     clear(176,15,1);
  337.     dlay(18*3);
  338.  
  339.     Twindow warray[8];
  340.     for(int i=0;i<8;i++) {
  341.         warray[i].init(18+(i*3),4+(i*2),20+(18+(i*3)),4+(4+(i*2)),i+1,i,1,7);
  342.         warray[i].setborder(DOUBLE);
  343.         warray[i].show();
  344.         }
  345.     Twindow newwindow;
  346.     newwindow.init(5,8,76,12,15,1,1,7);
  347.     newwindow.setborder(DOUBLE);
  348.     newwindow.zoom();
  349.     newwindow.wprintc(2,15,1,"Windows can overlap, and any underlying image is saved.");
  350.     dlay(18*4);
  351.  
  352.     newwindow.hide();
  353.     dlay(18);
  354.  
  355.     for(i=7;i>-1;i--) {
  356.         warray[i].hide();
  357.         dlay(18);
  358.         }
  359.  
  360.     Twindow newerwindow;
  361.     newerwindow.init(4,3,77,18,0,3,1,7);
  362.     newerwindow.setborder(DOUBLE);
  363.     newerwindow.zoom();
  364.     newerwindow.divider(HOR,DOUBLE,2);
  365.     newerwindow.wprintc(1,14,3,"***  Features  ***");
  366.  
  367.     printc(7,0,3,"What you have just seen is just a small sampling of the power");
  368.     printc(8,0,3,"that you control using the Twindow class of the ObjectEase");
  369.     printc(9,0,3,"library. Here is a listing of some additional features:");
  370.     printc(11,15,3,"Change foreground and background colors");
  371.     printc(12,15,3,"Print to a specific window");
  372.     printc(13,15,3,"Specify shadow or no shadow");
  373.     printc(14,15,3,"Have the window tell you all of it's details");
  374.     printc(15,15,3,"Never fear corrupted or lost memory, as a Twindow");
  375.     printc(16,15,3,"frees all of its accociated memory when it leaves scope");
  376.     dlay(18*4);
  377.  
  378.     printc(25,15+128,1,"Press <ENTER> to continue...");
  379. getkey:
  380.     while(!kbhit());
  381.     ch=getch();
  382.     if(ch==27) {
  383.         clrscr();
  384.         exit(0);
  385.         }
  386.     if(ch!=13) {
  387.         flushkeys();
  388.         goto getkey;
  389.         }
  390. }
  391.  
  392. //**************************************************************************
  393. //              MENUDEMO
  394. //**************************************************************************
  395.  
  396. void menudemo()
  397. {
  398.     char ch;
  399.  
  400.     clear(32,1,1);
  401.     dlay(12);
  402.     smover(12,1,38,14,1,"Menus");
  403.     dlay(18*2);
  404.     smover(12,38,76,14,1,"Menus");
  405.     clear(176,15,1);
  406.     dlay(18);
  407.     clear(176,15,1);
  408.  
  409.     Twindow textwindow;
  410.     textwindow.init(5,3,76,15,15,3,1,7);
  411.     textwindow.setborder(DOUBLE);
  412.     textwindow.zoom();
  413.     textwindow.divider(HOR,DOUBLE,2);
  414.     textwindow.wprintc(1,14,3,"Menus");
  415.  
  416.     printc(7,15,3,"The Tmenu class is descended from the Twindow class,");
  417.     printc(8,15,3,"therefore inheriting all of the member functions of the");
  418.     printc(9,15,3,"Twindow class. To use a Tmenu instance in its simplest form");
  419.     printc(10,15,3,"simply pass it the structure containing your menu selections");
  420.     printc(11,15,3,"and capture the returned value. We won't go into details");
  421.     printc(12,15,3,"as with the Twindow class, but rest assured the Tmenu class");
  422.     printc(13,15,3,"is just as powerful and as easy to implement!");
  423.     dlay(18*5);
  424.     printc(25,15+128,1,"Press <ENTER> to continue...");
  425.  
  426. getkey:
  427.     while(!kbhit());
  428.     ch=getch();
  429.     if(ch==27) {
  430.         clrscr();
  431.         exit(0);
  432.         }
  433.     if(ch!=13) {
  434.         flushkeys();
  435.         goto getkey;
  436.         }
  437.  
  438.     clear(176,15,1);
  439.     Tmenu demomenu;
  440.     itemarray items;
  441.  
  442.     strcpy(items[1],"Item number 1");
  443.     strcpy(items[2],"Item number 2");
  444.     strcpy(items[3],"Item number 3");
  445.     strcpy(items[4],"Continue");
  446.  
  447.     demomenu.init(4,items,10,13,20,15,1,14,5,1,8);
  448.     demomenu.title("Sample");
  449.     Twindow the_window;
  450.     the_window.init(15,4,66,8,15,1,1,7);
  451.     the_window.zoom();
  452.     printc(6,14,1,"Go ahead, experiment with this sample menu.");
  453.  
  454.     int done=0;
  455.     while(!done) {
  456.     int choice=demomenu.show();
  457.         switch(choice) {
  458.             case 1: demomenu.cfgd(7);
  459.                     printat(50,13,15,1,"You chose 1");
  460.                     printf("\a");
  461.                     dlay(18);
  462.                     demomenu.cfgd(15);
  463.                     continue;
  464.             case 2: demomenu.cfgd(7);
  465.                     printat(50,13,15,1,"You chose 2");
  466.                     printf("\a");
  467.                     dlay(18);
  468.                     demomenu.cfgd(15);
  469.                     continue;
  470.             case 3: demomenu.cfgd(7);
  471.                     printat(50,13,15,1,"You chose 3");
  472.                     printf("\a");
  473.                     dlay(18);
  474.                     demomenu.cfgd(15);
  475.                     continue;
  476.             case 4: demomenu.cfgd(7);
  477.                     done=1;
  478.                     dlay(9);
  479.                     continue;
  480.             }//switch
  481.         }//done
  482.     demomenu.hide();
  483.     clear(176,15,1);
  484. }
  485.  
  486. //**************************************************************************
  487. //              STRINGDEMO
  488. //**************************************************************************
  489.  
  490. void stringdemo()
  491. {
  492.     char ch;
  493.  
  494.     clear(32,1,1);
  495.     dlay(12);
  496.     smover(12,1,37,14,1,"Strings");
  497.     dlay(18*2);
  498.     smover(12,37,74,14,1,"Strings");
  499.     clear(176,15,1);
  500.  
  501.     Twindow the_window;
  502.     the_window.init(5,3,76,16,0,3,1,7);
  503.     the_window.setborder(DOUBLE);
  504.     the_window.zoom();
  505.     the_window.divider(HOR,DOUBLE,2);
  506.     printc(4,14,3,"String Input");
  507.  
  508.     printc(7,15,3,"The Tstring class is going to be your best friend. There is");
  509.     printc(8,15,3,"NO easier way to get user input in such a variety of formats.");
  510.     printc(9,15,3,"The Tstring class has two descendants, Tnumeral and Tdate");
  511.     printc(10,15,3,"which allow you to capture and convert any data type.");
  512.     printc(11,15,3,"Have you ever tried to design a form that would let the user");
  513.     printc(12,15,3,"move to any desired input field, up or down, back and forth?");
  514.     printc(13,15,3,"If you have, I'm sure you've met with the same frustration as");
  515.     printc(14,15,3,"most other programmers. Your headaches are now over...");
  516.     dlay(18*5);
  517.  
  518.     printc(25,15+128,1,"Press <ENTER> to continue");
  519. getkey:
  520.     while(!kbhit());
  521.     ch=getch();
  522.     if(ch==27) {
  523.         clrscr();
  524.         exit(0);
  525.         }
  526.     if(ch!=13) {
  527.         flushkeys();
  528.         goto getkey;
  529.         }
  530.     the_window.hide();
  531.     clear(176,15,1);
  532.  
  533.     Twindow formwindow;
  534.     formwindow.init(10,5,71,17,14,2,1,7);
  535.     formwindow.title("Input");
  536.     formwindow.show();
  537.  
  538.     Tstring lname;
  539.     Tstring fname;
  540.     Tstring address;
  541.     Tstring csz;
  542.     Tnumeral age;
  543.  
  544.     lname.init(40,7,15,0);
  545.     lname.setincolors(15,0);
  546.     fname.init(40,9,10,0);
  547.     fname.setincolors(15,0);
  548.     address.init(40,11,20,0);
  549.     address.setincolors(15,0);
  550.     csz.init(40,13,25,0);
  551.     csz.setincolors(15,0);
  552.     age.init(40,15,2,0);
  553.     age.setincolors(15,0);
  554.  
  555.     printc(2,14,1,"Try this one on for size...");
  556.     printc(3,14,1,"Notice that all of the standard editing keys are available.");
  557.  
  558.     printat(15,7,14,2,"Last name: ");
  559.     lname.show();
  560.     printat(15,9,14,2,"First name: ");
  561.     fname.show();
  562.     printat(15,11,14,2,"Address: ");
  563.     address.show();
  564.     printat(15,13,14,2,"City, State, Zip: ");
  565.     csz.show();
  566.     printat(15,15,14,2,"Age: ");
  567.     age.show();
  568.  
  569.     cursoron();
  570. getlname:
  571.     lname.get_form_input();
  572.     if(lname.uparrowhit())
  573.         goto getage;
  574.     if(lname.dnarrowhit())
  575.         goto getfname;
  576. getfname:
  577.     fname.get_form_input();
  578.     if(fname.dnarrowhit())
  579.         goto getaddress;
  580.     if(fname.uparrowhit())
  581.         goto getlname;
  582. getaddress:
  583.     address.get_form_input();
  584.     if(address.uparrowhit())
  585.         goto getfname;
  586.     if(address.dnarrowhit())
  587.         goto getcsz;
  588. getcsz:
  589.     csz.get_form_input();
  590.     if(csz.uparrowhit())
  591.         goto getaddress;
  592.     if(csz.dnarrowhit())
  593.         goto getage;
  594. getage:
  595.     age.get_form_input();
  596.     if(age.uparrowhit())
  597.         goto getcsz;
  598.     if(age.dnarrowhit())
  599.         goto getlname;
  600.  
  601.     cursoroff();
  602.     vprintat(35,20,15,1,"%s %s",fname.getstring(),lname.getstring());
  603.     vprintat(35,21,15,1,"%s",address.getstring());
  604.     vprintat(35,22,15,1,"%s",csz.getstring());
  605.     vprintat(35,23,15,1,"%d",age.getint());
  606.     dlay(18*2);
  607.  
  608.     formwindow.hide();
  609.     clear(176,15,1);
  610.  
  611.     the_window.zoom();
  612.     printc(5,14,3,"Additional features");
  613.     printc(7,15,3,"Force strings to all capitals");
  614.     printc(8,15,3,"Detect <ENTER>, <ESC>, <TAB>, <UP ARROW>, <DN ARROW>");
  615.     printc(9,15,3,"<HOME>, <END>, <BACKSPACE>, <DEL>, as well as mouse keypresses");
  616.     printc(10,15,3,"Return numerals as ints, floats, or longs");
  617.     printc(11,15,3,"Change the colors of the input fields");
  618.     printc(12,15,3,"Format and verify date fields");
  619.     dlay(18*5);
  620.  
  621.     flushkeys();
  622.     printc(25,15+128,1,"Press <ENTER> to continue...");
  623.     getch();
  624. }
  625.  
  626. //**************************************************************************
  627. //              BUTTONDEMO
  628. //**************************************************************************
  629.  
  630. void buttondemo()
  631. {
  632.     int done=0;
  633.     char ch;
  634.  
  635.     clear(32,1,1);
  636.     dlay(12);
  637.     smover(12,1,37,14,1,"Buttons");
  638.     dlay(18*2);
  639.     smover(12,37,74,14,1,"Buttons");
  640.     clear(176,15,1);
  641.     dlay(9);
  642.  
  643.     Twindow demowindow;
  644.     demowindow.init(5,3,76,18,15,3,1,7);
  645.     demowindow.setborder(DOUBLE);
  646.     demowindow.zoom();
  647.     demowindow.divider(HOR,DOUBLE,2);
  648.  
  649.     printc(4,14,3,"Buttons");
  650.  
  651.     printc(7,15,3,"Pushbuttons provide yet another easy way to get input from");
  652.     printc(8,15,3,"the users of your applications. There are times when a menu");
  653.     printc(9,15,3,"is just too much, and that's when a pushbutton can serve the");
  654.     printc(10,15,3,"purpose perfectly. Pushbuttons can be activated by any trigger");
  655.     printc(11,15,3,"you choose, but the most common trigger is the ALT key combined");
  656.     printc(12,15,3,"with the highlighted letter, or of course the mouse.");
  657.     printc(13,15,3,"Give these buttons a try to get a feel for their use...");
  658.  
  659.     Tbutton button1;
  660.     button1.init(20,15,"Button 1",1);
  661.     Tbutton button2;
  662.     button2.init(35,15,"Button 2",2);
  663.     Tbutton button3;
  664.     button3.init(50,15,"Continue",1);
  665.  
  666.     button1.show(3);
  667.     button2.show(3);
  668.     button3.show(3);
  669.  
  670.     while(!done) {
  671.         if(kbhit()) {
  672.             ch=getch();
  673.             if(altkey()) {
  674.                 ch=getch();
  675.                 switch(ch) {
  676.                     case ALTB:      button1.press(3);
  677.                                 while(altkey());
  678.                                 button1.show(3);
  679.                                 continue;
  680.                     case ALTU:      button2.press(3);
  681.                                 while(altkey());
  682.                                 button2.show(3);
  683.                                 continue;
  684.                     case ALTC:      button3.press(3);
  685.                                 while(altkey());
  686.                                 button3.show(3);
  687.                                 done=1;
  688.                                 continue;
  689.                     }
  690.                 }//if altkey
  691.             else
  692.                 flushkeys();
  693.             }//if kbhit
  694.         }//while
  695.     clear(176,15,1);
  696. }
  697.  
  698. //*************************************************************************
  699. //              CHECKBOXDEMO
  700. //*************************************************************************
  701.  
  702. void checkboxdemo()
  703. {
  704.     char ch;
  705.     int done=0;
  706.  
  707.     clear(32,1,1);
  708.     dlay(12);
  709.     smover(12,1,35,14,1,"Checkboxes");
  710.     dlay(18*2);
  711.     smover(12,35,71,14,1,"Checkboxes");
  712.     clear(176,15,1);
  713.     dlay(9);
  714.  
  715.     Twindow the_window;
  716.     the_window.init(5,3,76,19,15,3,1,7);
  717.     the_window.setborder(DOUBLE);
  718.     the_window.zoom();
  719.     the_window.divider(HOR,DOUBLE,2);
  720.     printc(4,14,3,"Checkboxes");
  721.  
  722.  
  723.     printc(7,15,3,"One final way to capture user input is through the use of");
  724.     printc(8,15,3,"checkboxes. Checkboxes can provide the user with a means of");
  725.     printc(9,15,3,"making multiple selections. All your program needs to do");
  726.     printc(10,15,3,"\"ask\" the checkbox if it has been checked or not. The");
  727.     printc(11,15,3,"POWER of the object! The spacebar or the mouse is generally");
  728.     printc(12,15,3,"the trigger to toggle a checkbox's state, however, you may");
  729.     printc(13,15,3,"employ any trigger you choose. Try these samples using the");
  730.     printc(14,15,3,"<TAB> key to move among the checkboxes. Check the CONTINUE");
  731.     printc(15,15,3,"box and press <ENTER> when done.");
  732.  
  733.     Tcheckbox check1;
  734.     check1.init(25,17,14,3);
  735.     Tcheckbox check2;
  736.     check2.init(40,17,14,3);
  737.     Tcheckbox check3;
  738.     check3.init(55,17,14,3);
  739.  
  740.     printat(15,17,15,3,"Check #1:");
  741.     check1.show();
  742.     printat(30,17,15,3,"Check #2:");
  743.     check2.show();
  744.     printat(45,17,15,3,"Continue:");
  745.     check3.show();
  746.  
  747.     cursoron();
  748.     check1.grabcursor();
  749.  
  750.     int active1=1,active2=0,active3=0;
  751.     while(!done) {
  752.         if(kbhit()) {
  753.             ch=getch();
  754.             if(ch!=32 && ch!=9 && ch!=13) {
  755.                 flushkeys();
  756.                 continue;
  757.                 }
  758.             if(ch==32) {
  759.                 if(active1) {
  760.                     if(check1.ischecked())
  761.                         check1.uncheck();
  762.                     else
  763.                         check1.check();
  764.                     }
  765.                 if(active2) {
  766.                     if(check2.ischecked())
  767.                         check2.uncheck();
  768.                     else
  769.                         check2.check();
  770.                     }
  771.                 if(active3) {
  772.                     if(check3.ischecked())
  773.                         check3.uncheck();
  774.                     else
  775.                         check3.check();
  776.                     }
  777.                 }//ch==32
  778.             if(ch==9) {
  779.                 if(active1) {
  780.                     check2.grabcursor();
  781.                     active1=0;
  782.                     active2=1;
  783.                     continue;
  784.                     }
  785.                 if(active2) {
  786.                     check3.grabcursor();
  787.                     active2=0;
  788.                     active3=1;
  789.                     continue;
  790.                     }
  791.                 if(active3) {
  792.                     check1.grabcursor();
  793.                     active3=0;
  794.                     active1=1;
  795.                     continue;
  796.                     }
  797.                 }//ch==9;
  798.             if(ch==13) {
  799.                 if(check3.ischecked()) {
  800.                     done=1;
  801.                     continue;
  802.                     }
  803.                 }
  804.             }//kbhit
  805.         }//!done
  806.     cursoroff();
  807.     clear(176,15,1);
  808.     dlay(18*1);
  809. }
  810.  
  811. //**************************************************************************
  812. //              TEXTMOUSEDEMO
  813. //**************************************************************************
  814.  
  815. void textmousedemo()
  816. {
  817.     int done=0;
  818.     char ch;
  819.  
  820.     Twindow top;
  821.     top.init(1,1,80,4,15,1,0,0);
  822.     top.zoom();
  823.     printc(2,14,1,"OK, now let's put it all to use. If you have a mouse,");
  824.     printc(3,14,1,"use it also to select any field or option you choose.");
  825.  
  826.     Twindow form;
  827.     form.init(5,6,76,15,15,3,1,7);
  828.     form.setborder(DOUBLE);
  829.     form.show();
  830.  
  831.     Tstring lname;
  832.     Tstring fname;
  833.  
  834.     Tbutton donebutton;
  835.     donebutton.init(55,11," Complete ",2);
  836.     Tcheckbox yesbox;
  837.     yesbox.init(45,11,15,3);
  838.     Tcheckbox nobox;
  839.     nobox.init(45,13,15,3);
  840.  
  841.     printat(10,7,14,3,"First name: ");
  842.     printat(10,9,14,3,"Last name:  ");
  843.     fname.init(25,7,10,0);
  844.     fname.setincolors(14,0);
  845.     fname.show();
  846.     lname.init(25,9,15,0);
  847.     lname.setincolors(14,0);
  848.     lname.show();
  849.  
  850.     printat(10,12,14,3,"Enjoying demo thus far?");
  851.     printat(40,11,14,3,"Yes");
  852.     printat(40,13,14,3,"No ");
  853.     yesbox.show();
  854.     nobox.show();
  855.     yesbox.check();
  856.  
  857.     donebutton.show(3);
  858.     the_mouse.arm();
  859.     cursoron();
  860.  
  861.     while(!done) {
  862. getfname:
  863.         fname.get_form_mouse_input();
  864.         if(the_mouse.LBP())
  865.             goto checkmouse;
  866.         if(fname.dnarrowhit() || fname.tabhit())
  867.             goto getlname;
  868.         if(fname.uparrowhit())
  869.             goto getdone;
  870. getlname:
  871.         lname.get_form_mouse_input();
  872.         if(the_mouse.LBP())
  873.             goto checkmouse;
  874.         if(lname.uparrowhit())
  875.             goto getfname;
  876.         if(lname.dnarrowhit() || lname.tabhit())
  877.             goto getyes;
  878. getyes:
  879.         yesbox.grabcursor();
  880.         while(!kbhit() && !the_mouse.LBP());
  881.         if(the_mouse.LBP())
  882.             goto checkmouse;
  883.         ch=getch();
  884.         if(ch==32) {
  885.             if(yesbox.ischecked()) {
  886.                 yesbox.uncheck();
  887.                 nobox.check();
  888.                 }
  889.             else {
  890.                 yesbox.check();
  891.                 nobox.uncheck();
  892.                 }
  893.             }
  894.         if(ch==9) {
  895.             flushkeys();
  896.             goto getno;
  897.             }
  898.         if(ch==0) {
  899.             ch=getch();
  900.             if(ch==80)
  901.                 goto getno;
  902.             if(ch==72)
  903.                 goto getlname;
  904.             flushkeys();
  905.             }
  906.         else {
  907.             flushkeys();
  908.             goto getyes;
  909.             }
  910. getno:
  911.         nobox.grabcursor();
  912.         while(!kbhit() && !the_mouse.LBP());
  913.         if(the_mouse.LBP())
  914.             goto checkmouse;
  915.         ch=getch();
  916.         if(ch==32) {
  917.             if(nobox.ischecked()) {
  918.                 nobox.uncheck();
  919.                 yesbox.check();
  920.                 }
  921.             else {
  922.                 nobox.check();
  923.                 yesbox.uncheck();
  924.                 }
  925.             }
  926.         if(ch==9) {
  927.             flushkeys();
  928.             goto getdone;
  929.             }
  930.         if(ch==0) {
  931.             ch=getch();
  932.             if(ch==80)
  933.                 goto getdone;
  934.             if(ch==72)
  935.                 goto getyes;
  936.             flushkeys();
  937.             }
  938.         else {
  939.             flushkeys();
  940.             goto getno;
  941.             }
  942.  
  943. getdone:
  944.         gotoxy(57,11);
  945.         while(!kbhit() && ! the_mouse.LBP());
  946.         if(the_mouse.LBP())
  947.             goto checkmouse;
  948.  
  949.         ch=getch();
  950.         if(altkey()) {
  951.             ch=getch();
  952.             if(ch==ALTC) {
  953.                 donebutton.press(3);
  954.                 while(altkey());
  955.                 donebutton.show(3);
  956.                 done=1;
  957.                 continue;
  958.                 }
  959.             }
  960.         if(ch==13) {
  961.             donebutton.press(3);
  962.             dlay(3);
  963.             donebutton.show(3);
  964.             done=1;
  965.             continue;
  966.             }
  967.         if(ch==9)
  968.             goto getfname;
  969.         if(ch==0) {
  970.             ch=getch();
  971.             if(ch==72)
  972.                 goto getno;
  973.             if(ch==80)
  974.                 goto getfname;
  975.             flushkeys();
  976.             }
  977.  
  978. checkmouse:
  979.         if(the_mouse.LBP()) {
  980.             if(fname.hit()) {
  981.                 while(the_mouse.LBP());
  982.                 goto getfname;
  983.                 }
  984.             if(lname.hit()) {
  985.                 while(the_mouse.LBP());
  986.                 goto getlname;
  987.                 }
  988.             if(yesbox.hit()) {
  989.                 if(yesbox.ischecked()) {
  990.                     yesbox.uncheck();
  991.                     nobox.check();
  992.                     while(the_mouse.LBP());
  993.                     }
  994.                 else {
  995.                     yesbox.check();
  996.                     nobox.uncheck();
  997.                     while(the_mouse.LBP());
  998.                     }
  999.                 goto getyes;
  1000.                 }
  1001.             if(nobox.hit()) {
  1002.                 if(nobox.ischecked()) {
  1003.                     nobox.uncheck();
  1004.                     yesbox.check();
  1005.                     while(the_mouse.LBP());
  1006.                     }
  1007.                 else {
  1008.                     nobox.check();
  1009.                     yesbox.uncheck();
  1010.                     while(the_mouse.LBP());
  1011.                     }
  1012.                 goto getno;
  1013.                 }
  1014.             if(donebutton.buttonpressed()) {
  1015.                 donebutton.press(3);
  1016.                 while(the_mouse.LBP());
  1017.                 donebutton.show(3);
  1018.                 done=1;
  1019.                 continue;
  1020.                 }
  1021.             }
  1022.         }//while !done
  1023.     cursoroff();
  1024.     the_mouse.unarm();
  1025. }
  1026.  
  1027. //**************************************************************************
  1028. //              WRAPUP
  1029. //**************************************************************************
  1030.  
  1031. void wrapup()
  1032. {
  1033.     clear(32,1,1);
  1034.     dlay(12);
  1035.     smoved(36,1,12,14,1,"Summary");
  1036.     dlay(18*2);
  1037.     smoveu(36,12,1,14,1,"Summary");
  1038.     clear(176,15,1);
  1039.     dlay(9);
  1040.  
  1041.     Twindow summwindow;
  1042.     summwindow.init(4,3,77,19,14,2,1,7);
  1043.     summwindow.show();
  1044.     summwindow.divider(HOR,DOUBLE,2);
  1045.     summwindow.wprintc(1,15,2,"Text Mode Features");
  1046.  
  1047.     printc(7,14,2,"You have now seen the richness of the features available");
  1048.     printc(8,14,2,"in the text mode objects of the ObjectEase class library.");
  1049.     printc(9,14,2,"Understand that this demo does not allow for all of the member");
  1050.     printc(10,14,2,"functions to be demonstrated. You, the programmer, have total");
  1051.     printc(11,14,2,"control over every aspect of these objects. End the cycle of");
  1052.     printc(12,14,2,"re-inventing the wheel... use these objects to piece together");
  1053.     printc(13,14,2,"application after application maintaining consistency and ease");
  1054.     printc(14,14,2,"of use. Object oriented technology makes application development");
  1055.     printc(15,14,2,"so much easier for the programmer. You need to take advantage");
  1056.     printc(16,14,2,"of this power NOW, or be left behind in the 1990's!");
  1057.     dlay(18*8);
  1058.  
  1059.     printc(25,15+128,1,"Press <ENTER> to continue...");
  1060.     getch();
  1061. }
  1062.